Vector2D = {}
Vector2D.__index = Vector2D

function Vector2D.Create(x, y)
  local vec2D = {}
  setmetatable(vec2D, Vector2D)
  vec2D.x = x
  vec2D.y = y
  return vec2D
end

function Vector2D:Normalize()
  local mag = self:GetMagnitude()
  self.x = self.x / mag
  self.y = self.y / mag
end

function Vector2D:GetMagnitude()
  return math.sqrt(self:MagSquared())
end

function Vector2D:MagSquared()
  return self.x*self.x + self.y*self.y
end

function Vector2D:GetAngle()
  local angle = math.atan2(self.y, self.x)
  if (angle < 0) then
    angle = angle + (2 * math.pi)
  end
  return angle
end

function Vector2D:GetAngleOfMouse()
  local mX = love.mouse.getX()
  local mY = love.mouse.getY()
  local dif = Vector2D.Create(self.x - mX, self.y - mY)
  return self:GetAngle(dif)
end

function toInt(n)
    local s = tostring(n)
    local i, j = s:find('%.')
    if i then
        return tonumber(s:sub(1, i-1))
    else
        return n
    end
end